package com.zw.user.controller;/*
 *@program:java-cloud-prevalence
 *@author:
 *@Time: 2022/12/5  16:18
 *@description: 后台页面登录控制类
 */

import com.zw.object.result.Result;
import com.zw.object.vo.LoginVo;
import com.zw.user.service.SysUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

@Api(tags = "用户登录接口")
@RestController
@RequestMapping("/admin/system/index")
public class LoginController {
    @Autowired
    private SysUserService sysUserService;

    /**
     *                  用户登录
     * @param loginVo   用户登录参数实体类
     * @return          Result
     */
    @ApiOperation("用户登录")
    @PostMapping("/login")
    public Result login(@RequestBody LoginVo loginVo){
        return sysUserService.Login(loginVo);
    }
    /**
     * 获取用户信息
     * @return
     */
    @ApiOperation("用户信息")
    @GetMapping("/info")
    public Result info(HttpServletRequest request) {
        String token = request.getHeader("token");
        return sysUserService.info(token);
    }
    /**
     * 退出
     * @return
     */
    @ApiOperation("用户登出")
    @PostMapping("/logout")
    public Result logout(){
        return Result.ok();
    }
}
